package com.ziki.test.socket.util;

public class Maths {
    /**
     * String转float
     * 
     * @param value
     * @return
     */
    public static final float atof(String value) {
        float result = 0f;
        if (value == null || value.trim().equals("")) {
            return result;
        }
        try {
            result = Float.parseFloat(value.trim());
        } catch (Exception ex) {

        }
        return result;
    }

    /**
     * String转int
     * 
     * @param value
     * @return
     */
    public static final int atoi(String value) {
        int result = 0;
        if (value == null || value.trim().equals("")) {
            return 0;
        }
        try {
            result = Integer.parseInt(value.trim());
        } catch (Exception ex) {
        }
        return result;
    }

    /**
     * int转String
     * 
     * @param value
     * @return
     */
    public static final String itoa(int value) {
        String result = "";
        try {
            result = String.valueOf(value);
        } catch (Exception ex) {
        }
        return result;
    }

    /**
     * String转long
     * 
     * @param value
     * @return
     */
    public static final long atol(String value) {
        if (value == null || value.trim().equals("")) {
            return 0;
        }
        return Long.parseLong(value);
    }
}
